<!DOCTYPE html>  
<html lang="en">  
<head>   
  <meta charset="UTF-8">   
  <title></title>  
</head>  
<body onload="draw();">
    <canvas id="canvas" width="200" height="100" style="border:1px solid red">
          <p>写在这里面的内容将展示给不兼容canvas的浏览器</p>
    </canvas>
</body>
<script type="text/javascript"> 
  function draw() { 
      //第一步：获取canvas元素
      canvas = document.getElementById("canvas");
      //第二步：获取上下文
      ctx = canvas.getContext("2d"); 
      console.log(ctx);
  }
</script>
</html>
